<?php
declare (strict_types = 1);
namespace app\api\model;

class MemberSite extends Base
{
    /**
     * 修改一条数据
     * @param int $uid:会员ID
     * @return array|false
     */
    public function edit_one_data($robotId,$data)
    {
        $data=json_decode($data,true);



        $data=array_merge($data['hxpz'],$data['tlj'],$data['fxz'],$data['zjy']);


        if (empty($data['is_danpin_fanhui_kapian_tb'])){
            var_dump('1');
        }
        $user = $this->where('robot_id',$robotId)->where('uid',session('admin.id'))->find();
        //判断数据
        if($user){
            //有找到
            $data['robot_id']=$robotId;
            $res=$this->update($data,['id'=>$user['id']]);
            return $res ? ['code' => 1, 'msg' => '更新文案成功','statusId'=>'#status_'.$robotId] : ['code' => 0, 'msg' => '更新文案失败'];

        }else {
            //没有找到
            return ['code'=>0,'msg'=>'提交参数异常'];
        }
    }

    /**
     * 获取一条数据
     * @param int $uid:会员ID
     * @return array|false
     */
    public function get_datas($robotId,$configreName)
    {
        if($configreName=='checkCoupon'){
            return $this->where('robot_id',$robotId)->find();


        }elseif ($configreName=='fan555Li') {
            $robotId='gh_80bb762dd2d9';
            return $this->where('robot_id',$robotId)->find();
        }else{
            return $this->where('robot_id',$robotId)->find();
        }


    }


}